package com.xd.Controller.admin.XTGLY;
import com.github.pagehelper.PageInfo;
import com.xd.Entity.addBrandProductEntity;
import com.xd.Entity.addBrandProductEntityImpr;
import com.xd.Result.CommonResult;
import com.xd.service.admin.XTGLY.brand.impl.updateBrandServiceImpl;
import com.xd.service.admin.XTGLY.impl.addBrandServiceImpl;
import com.xd.service.admin.XTGLY.impl.selectBrandServiceImpl;
import com.xd.vo.UpdateBrand;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pojo.CommonPojo;
import pojo.XTGLY.addBrandProduct;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/admin")
public class AddProductBrandController {
    @Autowired
    addBrandServiceImpl addBrandService;
    @Autowired
    selectBrandServiceImpl selectBrandService;
    @Autowired
    updateBrandServiceImpl updateBrandService;

    /**
     * 新增商品品牌
     */
    @PostMapping("/addBrand")
    public CommonResult getProduct(@RequestBody addBrandProduct addBrand){
        addBrandProductEntity addBrandProductEntity = new addBrandProductEntity();

        BeanUtils.copyProperties(addBrand,addBrandProductEntity);
        LocalDateTime creatTime = LocalDateTime.now();
        addBrandProductEntity.setCreatTime(creatTime);
                        addBrandService.addBrand(addBrandProductEntity);
                        return CommonResult.Success();
    }
    /**
     * 根据某个条件查询商品品牌
     */
    @GetMapping("/ifProduct/getBrand")
    public CommonResult<PageInfo<addBrandProductEntityImpr>> getBrandIf(CommonPojo commonPojo){
      PageInfo  Page =selectBrandService.selectBrandIf(commonPojo);
      return CommonResult.Success(Page);

    }
    /**
     *修改商品品牌接口
     */
    @PostMapping("/updateBrand")
    public CommonResult updateBrand(@RequestBody UpdateBrand updateBrand){
        updateBrandService.updateBrand(updateBrand);
        return CommonResult.Success();
    }
    /**
     *
     */
}
